import { apiDecorateMange } from 'js/api'

export default {
  state: {
    adsList: [],
    par: {
      accessToken: '',
      threeMenuCode: '',
      currentPage: 1,
      showCount: 99
    }
  },
  getters: {
    adsList: state => state.adsList
  },
  actions: {
    /**
     * 获取 广告位 列表
     */
    fetchAdsList({ state }, params) {
      state.par.accessToken = params.token
      state.par.threeMenuCode = params.three || ''

      apiDecorateMange.getAdsList(state.par).then(data => {
        let list = data.data.recordList || {}
        list = list.filter(item => {
          return item.apStatus == '1'
        })
        state.adsList = list.map(val => {
          return {
            value: val.id,
            label: val.apTitle
          }
        })
        // state.adsList.unshift({value: '', label: '请选择'})
      })
    }
  }
}